import axios from 'axios'

let error = console.error

const api = '/product-templates'

export function getTemplate (id, cb, fcb = () => error('getTemplate')) {
  axios.get(api + '/' + id).then(res => {
    let data = res.data
    cb(data)
  }).catch(error => {
    fcb(error)
  })
}

export function saveTemplate (params, cb, fcb = () => error('saveTemplate')) {
  axios.post(api, params).then(res => {
    let data = res.data
    cb(data)
  }).catch(error => {
    fcb(error)
  })
}

export function deleteTemplate (id, cb, fcb = () => error('deleteTemplate')) {
  axios.delete(api + '/' + id).then(res => {
    let data = res.data
    cb(data)
  }).catch(error => {
    fcb(error)
  })
}
